if (typeof tyNamespace.WarningSectencesIndex == "undefined") {
	tyNamespace.WarningSectencesIndex = {};
	tyNamespace.WarningSectencesIndex.OffLine = 20;
	tyNamespace.WarningSectencesIndex.PoChan = 27;
	tyNamespace.WarningSectencesIndex.Update = 22;
	tyNamespace.WarningSectencesIndex.NoGold = 32;
	tyNamespace.WarningSectencesIndex.NoDiamond = 33;
	tyNamespace.WarningSectencesIndex.NoVoucher = 34;
}
tyNamespace.WarningLayer = cc.Layer.extend({
	btType:null,
	WarningSectencesIndex:null,
	callback:null,

	ctor:function(btType,WarningSectencesIndex,callback){
		this._super();
		if(btType){
			this.btType = btType;
		}
		if(WarningSectencesIndex){
			this.WarningSectencesIndex = WarningSectencesIndex;
		}
		if(callback){
			this.callback = callback;
		}
		this.init();
	},
	init: function () {
		cc.spriteFrameCache.addSpriteFrames(gpNamespace.warningRes.Warning_plist);
		cc.spriteFrameCache.addSpriteFrames(gpNamespace.pdkTanKuangRes.tankuang_plist);
		var background = new cc.Sprite(gpNamespace.tankuang.jingaobackground);
		background.attr({
			x: cc.winSize.width/2,
			y: cc.winSize.height/2
		});
		this.addChild(background);

		var sentence = null;
		switch (this.WarningSectencesIndex) {
		case tyNamespace.WarningSectencesIndex.PoChan:
			sentence = new cc.Sprite(gpNamespace.warning.Warning_Sentence27);
			break;
		case tyNamespace.WarningSectencesIndex.NoGold:
			sentence = new cc.Sprite(gpNamespace.warning.Warning_Sentence32);
			break;
		case tyNamespace.WarningSectencesIndex.NoDiamond:
			cc.log("NoDiamond");
			sentence = new cc.Sprite(gpNamespace.warning.Warning_Sentence33);
			break;
		case tyNamespace.WarningSectencesIndex.NoVoucher:
			sentence = new cc.Sprite(gpNamespace.warning.Warning_Sentence34);
			break;
		default:
			sentence = new cc.LabelTTF("你特么点的哪儿的啊！",gpNamespace.DEFAULTFONT,30);
			sentence.setFontFillColor(cc.color(108, 28, 11, 255));
		break;
		}

		sentence.attr({
			x: background.width / 2,
			y: 212 ,
		});
		background.addChild(sentence);

		var menuItems = [];

		if(this.btType == 3){//特殊情况破产
			var confirm = new cc.MenuItemImage(gpNamespace.warning.Warning_GetAllowance,gpNamespace.warning.Warning_GetAllowance,this.confirmCallback,this);
			confirm.attr({
				x: 90,
				y: 15,
				anchorX: 0,
				anchorY: 0
			});
			confirm.setUserData(this);
			menuItems.push(confirm);
			var charge = new cc.MenuItemImage(gpNamespace.tankuang.quxiao,gpNamespace.tankuang.quxiao,this.cancelCallback,this);
			charge.attr({
				x: 335,
				y: 25,
				anchorX: 0,
				anchorY: 0
			});
			charge.setUserData(this);
			menuItems.push(charge);
		}else if(this.btType == 2){
			var confirm = new cc.MenuItemImage(gpNamespace.tankuang.queding,gpNamespace.tankuang.queding,this.confirmCallback,this);
			confirm.attr({
				x: 90,
				y: 25,
				anchorX: 0,
				anchorY: 0
			});
			confirm.setUserData(this);
			menuItems.push(confirm);
			var cancel = new cc.MenuItemImage(gpNamespace.tankuang.quxiao,gpNamespace.tankuang.quxiao,this.cancelCallback,this);
			cancel.attr({
				x: 335,
				y: 25,
				anchorX: 0,
				anchorY: 0
			});
			cancel.setUserData(this);
			menuItems.push(cancel);
		}else{
			var confirm = new cc.MenuItemImage(gpNamespace.tankuang.queding,gpNamespace.tankuang.queding,this.confirmCallback,this);
			confirm.attr({
				x: 212,
				y: 25,
				anchorX: 0,
				anchorY: 0
			});
			confirm.setUserData(this);
			menuItems.push(confirm);
		}

		var menu = new cc.Menu(menuItems);
		menu.attr({
			x:0,
			y:0,
			anchorX: 0,
			anchorY: 0
		});
		background.addChild(menu);
	},
	cancelCallback:function(sender){
		cc.log("cancelCallback");
		var self = sender.getUserData();
		self.getParent().getParent().removeFromParent(true);
	},
	confirmCallback:function(sender){
		cc.log("confirmCallback");
		var self = sender.getUserData();
		if(self.callback != null){
			self.callback.apply(self);
		}
		self.getParent().getParent().removeFromParent(true);
	}
})